const path = require("path");

function getImportHandleCssCode(loaderContext) {
  //返回handle-css.js所在的路径，与被处理css文件所在的路径之间的相对路径

  //找到handle-css.js的路径
  const handleCssPath = path.resolve(__dirname, "runtime/handle-css.js");

  console.log(handleCssPath, "handleCssPath");

  //找到css的路径:loaderContext.context
  //使用loaderContext.utils.contextify来计算相对路径
  const relativePath = loaderContext.utils.contextify(
    loaderContext.context,
    handleCssPath
  );

  console.log(
    relativePath,
    "relativePath",
    `import handleCss from ${JSON.stringify(relativePath)}`
  );

  return `import handleCss from ${JSON.stringify(relativePath)}`;
}

module.exports = getImportHandleCssCode;
